﻿namespace Arms.Persistence
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Core.Objects;
    using System.Data.Entity.Infrastructure;

    /// <summary>
    /// Base contract for EntityFramework's DbContext
    /// </summary>
    public interface IDbContext : IDisposable
    {
        /// <summary>
        /// Provides access to features of the context that deal with change tracking of entities.
        /// </summary>
        DbChangeTracker ChangeTracker { get; }
        /// <summary>
        /// Underlying object context.
        /// </summary>
        ObjectContext ObjectContext { get; }
        /// <summary>
        /// Collection of Entity.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        DbSet<T> Set<T>() where T : class;
        /// <summary>
        /// Entity change tracker.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <returns></returns>
        DbEntityEntry<T> Entry<T>(T entity) where T : class;
        /// <summary>
        /// Save changes to database.
        /// </summary>
        /// <returns></returns>
        int SaveChanges();
    }
}
